package 强化训练;

import java.util.Scanner;

public class day16扑克牌大小 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] strs = s.split("-");
        String[] str1 = strs[0].split(" ");
        String[] str2 = strs[1].split(" ");
        String sample = "34567891JQKA2";
        if ("joker JOKER".equals(str1) || "joker JOKER".equals(str2)){
            System.out.println("joker JOKER");
        }else if (str1.length == str2.length){//两手牌得长度相等
            if (sample.indexOf(str1[0].charAt(0)) < sample.indexOf(str2[0].charAt(0))){//比较谁得第一张牌在sqmple中先出现
                System.out.println(strs[1]);
            }else {
                System.out.println(strs[0]);
            }
        } else if (str1.length == 4) {
            System.out.println(strs[0]);
        }else if (str2.length == 4){
            System.out.println(strs[1]);
        }else {
            System.out.println("ERROR");
        }
    }

}
